
package com.ami.kvm.jviewer.soc;

import java.io.FileInputStream;
import java.nio.ByteBuffer;

import com.ami.kvm.jviewer.common.ISOCKvmClient;
import com.ami.kvm.jviewer.gui.JViewerApp;
import com.ami.kvm.jviewer.jvvideo.JVVideo;
import com.ami.kvm.jviewer.kvmpkts.IVTPPktHdr;
import com.ami.kvm.jviewer.kvmpkts.KVMClient;
import com.ami.kvm.jviewer.soc.reader.HardwareCursorReader;
import com.ami.kvm.jviewer.soc.video.VideoEngineConfigs;

public class SOCKVMclient implements ISOCKvmClient {
	private KVMClient client;
	private JVVideo video;
	private HardwareCursorReader hwCursorReader;
	private VideoEngineConfigs configs;

	public SOCKVMclient() {
		this.configs = new VideoEngineConfigs();
	}

	public void SetKVMClient(KVMClient paramKVMClient) {
		this.client = paramKVMClient;
	}

	public void SetVidoclnt(JVVideo paramJVVideo) {
		this.video = paramJVVideo;
	}

	public void SOCKVM_reader() {
		this.hwCursorReader = new HardwareCursorReader(this.client, this.video);
	}

	public Object getSOCReader(short paramShort) {
		if (paramShort == 4098) {
			return this.hwCursorReader;
		}

		return null;
	}

	public VideoEngineConfigs getVideoEngineConfigs() {
		return this.configs;
	}

	public void changeVideoEngineVGAStatus(byte paramByte) {
		this.configs.setVideoEngineVGAStatus(paramByte);
	}

	public void onSocControlMessage(IVTPPktHdr paramIVTPPktHdr, ByteBuffer paramByteBuffer) {
		switch (paramIVTPPktHdr.type) {
		case 4099:
			this.configs.setVideoEngineConfigs(paramByteBuffer);

			if (this.configs.compression_mode == 0) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("YUV_420", true);
			} else if (this.configs.compression_mode == 1) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("YUV_444", true);
			} else if (this.configs.compression_mode == 2) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("YUV_444_2_COLORS_VQ", true);
			} else if (this.configs.compression_mode == 3) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("YUV_444_4_COLORS_VQ", true);
			}
			if (this.configs.dct_quant_tbl_select == 0) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("DCT_Table_0", true);
			} else if (this.configs.dct_quant_tbl_select == 1) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("DCT_Table_1", true);
			} else if (this.configs.dct_quant_tbl_select == 2) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("DCT_Table_2", true);
			} else if (this.configs.dct_quant_tbl_select == 3) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("DCT_Table_3", true);
			} else if (this.configs.dct_quant_tbl_select == 4) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("DCT_Table_4", true);
			} else if (this.configs.dct_quant_tbl_select == 5) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("DCT_Table_5", true);
			} else if (this.configs.dct_quant_tbl_select == 6) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("DCT_Table_6", true);
			} else if (this.configs.dct_quant_tbl_select == 7) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("DCT_Table_7", true);
			}
			break;
		default:
			System.out.println("Invalid SoC Command");
		}
	}

	public void OnreadSOCVideoRecordData(FileInputStream paramFileInputStream) {
	}
}
